package org.hnsd.train.pattern.factory;

/**
 * 生产者实例类
 *
 * @author youqd
 * @tag.date 2023-11-01 10:59
 **/
public class ConcreteCreator implements ICreator{
    @Override
    public AbstractProduct produce(int num) {
        if(num == 1){
            return new Product1();
        }
        return new Product2();
    }

    public static void main(String[] args) {
        ICreator creator = new ConcreteCreator();
        AbstractProduct product1 = creator.produce(1);
        product1.produce();
        AbstractProduct product2 = creator.produce(2);
        product2.produce();
    }
}
